FROM golang:1.17-alpine3.15 as builder

WORKDIR /code

COPY . .

RUN wget -O satis.zip https://gitee.com/csingo/satis-go/repository/archive/master.zip \
    && ls -al \
    && unzip satis.zip \
    && ls -al \
    && cd satis-go-master \
    && cat config/vars/RouteConf.go \
    && go build -o bin/satis-go server/main.go

FROM alpine:3.15 as runner

COPY --from=builder /code/satis-go-master/bin/satis-go /satis-go
WORKDIR /data

ENV SATIS_ENABLE "true"
ENV SATIS_NAME "CSINGO / SATIS"
ENV SATIS_HOST "http://satis-go.csingo.com"
ENV SATIS_PACKAGES_PATH "/data"
ENV SATIS_CONCURRENT "50"
ENV SATIS_PUBLIC_EKY ""
ENV SATIS_PRIVATE_EKY ""
ENV SATIS_HTTP_PORT "80"
ENV SATIS_AUTH_USERNAME "admin"
ENV SATIS_AUTH_PASSWORD "admin123!@#"
ENV DB_HOST "127.0.0.1"
ENV DB_PORT "3306"
ENV DB_NAME "satis"
ENV DB_USERNAME "root"
ENV DB_PASSWORD "******"

RUN apk add --no-cache git openssh \
    && echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config

CMD ["/satis-go"]